﻿using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Text;

public partial class _Contacts : System.Web.UI.Page 
{
    protected LocalFunctions FUNC;
    protected string sKeywords, sDescription;

    protected void Page_Load(object sender, EventArgs e)
    {
        FUNC = ((Rondo)Master).FUNC;

        wmName.WatermarkText=FUNC.GetPhrase(26);
        wmLastName.WatermarkText = FUNC.GetPhrase(27);
        wmEmail.WatermarkText = FUNC.GetPhrase(28);
        wmPhone.WatermarkText = FUNC.GetPhrase(29);
        wmContent.WatermarkText=FUNC.GetPhrase(30);

        btnSend.Text = FUNC.GetPhrase(31);
        
        if (FUNC.LangID == 2)
            tblMain.Attributes.Add("dir", "rtl");
        

        Dal.arParams.Clear();
        Dal.arParams.Add(6); //Pagetype contacts
        Dal.arParams.Add(FUNC.LangID);
        DataTable DT = Dal.ExecuteDBsp("RD_SelectStaticPageById", Dal.arParams);
        
        if (DT != null)
        {
            if (DT.Rows.Count > 0)
            {
                Title = DT.Rows[0]["BrowserTitle"].ToString();
                sKeywords = DT.Rows[0]["Keywords"].ToString();
                sDescription = DT.Rows[0]["Description"].ToString();
                PageContent.InnerHtml = DT.Rows[0]["PageContent"].ToString();
                imgTitle.Src = FUNC.FullAppPath + "/Gallery/" + DT.Rows[0]["imageLink"].ToString();
            }
        }
    }
    protected void btnSend_Click(object sender, EventArgs e)
    {
        string sToEmail = Dal.ExecuteDBspOneValue("Admin_GetEmail", null).ToString();
        StringBuilder sb = new StringBuilder();

        sb.Append("Вы получили новое сообщение.<br />");
        sb.AppendFormat("Имя: {0}<br />", txtName.Text);
        sb.AppendFormat("Фамилия: {0}<br />", txtLastName.Text);
        sb.AppendFormat("Email: {0}<br />", txtEmail.Text);
        sb.AppendFormat("Телефон: {0}<br />", txtPhone.Text);
        sb.Append("Текст сообщения:<br />");
        sb.Append(txtContent.Text);

        //SendMail
        Helper.SendEmail(txtEmail.Text, txtName.Text, sToEmail, "Вы получили новое сообщение на BeaMonkey.",sb);
    }
}
